package com.ruoyi.master.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import feign.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.master.domain.TTaskUp;
import com.ruoyi.master.service.ITTaskUpService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 任务时长增长Controller
 * 
 * @author jiandan
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/up")
public class TTaskUpController extends BaseController
{
    @Autowired
    private ITTaskUpService tTaskUpService;

    /**
     * 查询任务时长增长列表selectTTaskUpListByTaskId
     */
    @RequiresPermissions("master:up:list")
    @GetMapping("/list")
    public TableDataInfo list(TTaskUp tTaskUp)
    {
        startPage();
        List<TTaskUp> list = tTaskUpService.selectTTaskUpList(tTaskUp);
        return getDataTable(list);
    }

    /**
     * 根据任务id查询任务时长增长列表
     */
//    @RequiresPermissions("master:up:list")
    @GetMapping("/listByTaskId")
    public TableDataInfo listByTaskId(@RequestParam Long taskId)
    {
        startPage();
        if(taskId == null){
            return getDataTable(null);
        }
        List<TTaskUp> list = tTaskUpService.selectTTaskUpListByTaskId(taskId);
        return getDataTable(list);
    }

    /**
     * 导出任务时长增长列表
     */
    @RequiresPermissions("master:up:export")
    @Log(title = "任务时长增长", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTaskUp tTaskUp)
    {
        List<TTaskUp> list = tTaskUpService.selectTTaskUpList(tTaskUp);
        ExcelUtil<TTaskUp> util = new ExcelUtil<TTaskUp>(TTaskUp.class);
        util.exportExcel(response, list, "任务时长增长数据");
    }

    /**
     * 获取任务时长增长详细信息
     */
    @RequiresPermissions("master:up:query")
    @GetMapping(value = "/{taskUpId}")
    public AjaxResult getInfo(@PathVariable("taskUpId") Long taskUpId)
    {
        return success(tTaskUpService.selectTTaskUpByTaskUpId(taskUpId));
    }

    /**
     * 新增任务时长增长
     */
    @RequiresPermissions("master:up:add")
    @Log(title = "任务时长增长", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTaskUp tTaskUp)
    {
        AjaxResult ajaxResult = toAjax(tTaskUpService.insertTTaskUp(tTaskUp));
        return ajaxResult;
    }

    /**
     * 修改任务时长增长
     */
    @RequiresPermissions("master:up:edit")
    @Log(title = "任务时长增长", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTaskUp tTaskUp)
    {
        return toAjax(tTaskUpService.updateTTaskUp(tTaskUp));
    }

    /**
     * 删除任务时长增长
     */
    @RequiresPermissions("master:up:remove")
    @Log(title = "任务时长增长", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskUpIds}")
    public AjaxResult remove(@PathVariable Long[] taskUpIds)
    {
        return toAjax(tTaskUpService.deleteTTaskUpByTaskUpIds(taskUpIds));
    }
}
